#include<stdio.h>

int search(int nums[], int target);

int main()
{
	int nums[] = { 0,1,2,3,4,5,6,7,8,9 };
	int target = 5;
	int res = search(nums, target);
	printf("%d", res);
	return 0;
}

int search(int nums[],int target)
{
	int j = 0, k = 9;
	while (j < k)
	{
		if (nums[j] == target) {
			return j;
		}
		else if (nums[k] == target) {
			return k;
			}
		else {
			j++;
			k--;
	}
		return -1;
}